package cc.wsyw126.java.collection.set;

/**
 * Created by junpeng.yang on 16/8/25.
 */

import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;


public class LinkedHashSetTest {
    public static void main(String[] args) {
    /*复制HashSet */
        Set h1 = new HashSet<String>();
        h1.add("List");
        h1.add("Queue");
        h1.add("Set");
        h1.add("Map");
        System.out.println("HashSet Elements:");
        System.out.print("\t" + h1 + "\n");
        Set h2 = copy(h1);
        System.out.println("HashSet Elements After Copy:");
        System.out.print("\t" + h2 + "\n");

        Set h3 = copyNoOrder(h1);
        System.out.println("HashSet Elements After Copy in No Order:");
        System.out.print("\t" + h3 + "\n");
    }

    @SuppressWarnings({
            "rawtypes",
            "unchecked"
    })

    public static Set copy(Set set) {
        Set setCopy = new LinkedHashSet(set);
        return setCopy;
    }

    public static Set copyNoOrder(Set set) {
        Set setCopy = new HashSet<>(set);
        return setCopy;
    }
}